package com.jdwx.opengl.face.utils;

import android.app.Activity;
import android.widget.Toast;

/**
 * ****************************
 * SPD_PDA_Module
 *
 * @AUTHER： YBB
 * CreateTime： 2019/7/9 16:53
 * Describe：
 * ****************************
 */
public class ToastUtil {
    /**
     * 显示提示
     *
     * @param activity
     * @param message  消息
     */
    public static void showToast(final Activity activity, final String message) {
        if ("main".equals(Thread.currentThread().getName())) {
            Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
        } else {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
                }
            });
        }
    }

    /**
     * 显示提示
     *
     * @param activity
     * @param resId    资源字典
     */
    public static void showToast(final Activity activity, int resId) {
        showToast(activity, activity.getResources().getString(resId));
    }
}
